import http from "../util/httpRequest.js"

//  订单支付，微信小程序下单 或 获取支付二维码和微信支付链接, 如果是JSPAY支付就需要wxCode
export function orderPay(params) {
	params.method = "POST"
	params.path = "/pay/orderPay/" + params.orderNo + "?payType=" + params.payType + "&wxCode=" + params.wxCode
	params.testData = function() {
		if (params.payType == "JSAPI") {
			return jspayPayDataTest
		} else if (params.payType == "NATIVE") {
			return nativePayDataTest
		}
		console.error("不支持的支付方式：" + params.payType)
		return {}
	}()
	params.showLoading = true
	http(params)
}

let jspayPayDataTest = {
	"appid": "wxa873ca2845a453df",
	"mch_id": "1618112867",
	"nonce_str": "pxlmOdaAnXCtMn0M",
	"prepay_id": "wx22200456595239fa85f9d48fb2686a0000",
	"result_code": "SUCCESS",
	"return_code": "SUCCESS",
	"return_msg": "OK",
	"sign": "13175AF8FB1E1AC50B27BB997DBA935A",
	"trade_type": "JSAPI"
}

let nativePayDataTest = {
	"appid": "wxa873ca2845a453df",
	"code_url": "weixin://wxpay/bizpayurl?pr=aWwqldgzz",
	"code_base64_img": "",
	"mch_id": "1618112867",
	"nonce_str": "0AjSo7gExxnYHCMj",
	"prepay_id": "wx22203302854667afd4ec1d5bf442ad0000",
	"result_code": "SUCCESS",
	"return_code": "SUCCESS",
	"return_msg": "OK",
	"sign": "7C98AF23518F0909856CB67198C40B23",
	"trade_type": "NATIVE",
}
